cd /data/data/com.termux/files/usr/.ACTS
if [ -d ".ACTS" ];then
echo "usr ...ok"
else
mkdir .ACTS
if [ -f "xml.xml" ];then
echo "xml.xml....ok"
else
wget wget https://gitee.com/ACTSpy/linux/raw/master/Minecraft/xml.xml
fi
fi
###检测脚本配置文件
nkt=$(sed -n "3p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'NK' | awk -F '=' '{print $2}')
mods=$(sed -n "5p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'mods' | awk -F '=' '{print $2}')
worlds=$(sed -n "7p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml  | grep 'worlds' | awk -F '=' '{print $2}')
sys=$(sed -n "9p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'sys' | awk -F '=' '{print $2}')
Backups=$(sed -n "11p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'Backups' | awk -F '=' '{print $2}')
http=$(sed -n "13p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'http' | awk -F '=' '{print $2}')
matrix=$(sed -n "17p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'matrix' | awk -F '=' '{print $2}')
preamplier=$(sed -n "19p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'preamplifier' | awk -F '=' '{print $2}')
sh=$(sed -n "25p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml   | grep 'sh' | awk -F '=' '{print $2}')
User=$(sed -n "23p" /data/data/com.termux/files/usr/.ACTS/User/xml.xml  | grep 'User' | awk -F '=' '{print $2}')
####
cd $User
if [ -f "user.txt" ];then
echo "\033[36m 文件检测中.."
sleep 2
echo "\033[32m 用户协议已通过 \033[0m"
sleep 1
reset
else
mkdir $User
echo "\033[34m 用户协议未通过请签署用户协议"
sh $sh/yh.sh
fi
if [ -f "user.txt" ];then
echo "\033[32m ok"
else
exit
fi
sleep 1;
zipsj=$( date +%Y:%m:%d-%S:%M%S )
cd $nkt
ml=$(pwd)
#以统计etc文件夹为例
if [ $? -eq 0 ];
  then
  lll=$(ls -l|grep "^-"|wc -l)
  dire_number=$(ls -l|grep "^d"|wc -l)
  soft_number=$(ls -l|grep "^L"|wc -l)
  hide_number=$(ls -a|grep "^\."|wc -l)
  #.需要加转义符\
  hide_file=$(ls -a|grep "^\."|grep -E '([0-9]|[a-z]|[A-Z]|_)')
  exfile_number=$(ls -l|grep "^-"|grep -E '(rwx|r-x)'|wc -l)
  #统计时去除.和..
fi
cd ~
e=[+]
c=[-]
ms=$(sed -n "16p" $nkt/server.properties | sed 's/[^0-9]//g')
rs=$(sed -n "12p" $nkt/server.properties | sed 's/[^0-9]//g')
a=$(sed -n "3p" $nkt/server.properties  | grep 'motd' | awk -F '=' '{print $2}')
n=$(sed -n "5p" $nkt/server.properties | sed 's/[^0-9]//g')
yx=$(ps -ef |grep java |grep -v "grep" |wc -l)
s=$( ls -l $nkt/plugins/* |wc -l)
echo "\033[32m $e ACTS  \033[0m"
echo "\033[33m $c ------------------基岩版服务器脚本------------------ \033[0m"
echo "\033[32m当前目录:$ml
文件数为： $lll
子文件夹数为：$dire_number
链接文件数为：$soft_number
当前时间：$zipsj\033[0m"
echo "\033[34m服务器mood数量:$s\033[0m              \033[34m  最大人数:$rs\033[0m"
echo "\033[33m服务器端口:$n\033[0m              \033[32m运行:$yx\033[0m"
echo "\033[32m游戏模式:$ms\033[0m        \033[32m服务器名:$a\033[0m"
echo "--------------------------功能---------------------------"
echo "[1]\033[32m $e 加载数据并启动服务器 \033[0m"
echo "[0]\033[33m $c 取消 \033[0m"
echo "[2]\033[32m $e 删除服务器文件 \033[0m"
echo "[3]\033[33m $c 修改端口 \033[0m"
echo "[4]\033[32m $e 修改模式 \033[0m"
echo "[5]\033[32m $c 修改服务器名字 \033[0m"
echo "[6]\033[32m $e 更新核心 \033[0m"
echo "[7]\033[33m $e 移除mood \033[0m"
echo "[8]\033[32m $e 上载mood  \033[0m"
echo "[9]\033[33m $c 备份/恢复服务器(文件) \033[0m"
echo "[10]\033[32m $e 修改服务器人数上限  \033[0m"
echo "--------------------------------------------------------"
read -p "序号: " xh
 case $xh in
0)
echo "取消"
;;
1)
cd $nkt
if [ -f "nukkit-1.0-SNAPSHOT.jar" ];then
echo "\033[32m $e 核心存在 \033[0m"
echo "\033[32m $e 校验服务器文件 \033[0m"
echo "\033[32m $e 运行服务器 \033[0m"
sleep 1
echo "\033[32m $e 执行服务器文件 \033[0m"
java -server -jar nukkit-1.0-SNAPSHOT.jar
sh $sh/mctermux.sh 
else
pkg install openjdk-17
sleep 1
echo "\033[32m $e 安装wegt \033[0m"
apt-get install wget
sleep 1
echo "\033[32m $e 创建文件目录 \033[0m"
mkdir $nkt
sleep 1
echo "\033[32m $e 创建moods文件目录>$sys/NK/moods \033[0m"
mkdir $sys
mkdir $sys/Backups
mkdir $sys/mod
mkdir $sys/moods
mkdir $sys/worlds
ln -s $sys/moods/ $nkt
sleep 2
mv $nkt/moods $nkt/plugins
sleep 1
echo "\033[32m $e 创建worlds文件目录>$sys/NK/worlds/ \033[0m"
ln -s $sys/worlds/ $nkt
sleep 1
echo "\033[32m $e 进入服务器目录 \033[0m"
cd $nkt
sleep 1
echo "\033[32m $e 下载服务器核心 \033[0m"
echo "\033[32m $c 核心:Nukkit \033[0m"
wget $http
java $preamplier -jar $nkt/nukkit-1.0-SNAPSHOT.jar
fi
sh $sh/mctermux.sh 
 ;;
 2)
read -r -p "是否删除服务器文件? [Y/n] " input
case $input in
    [yY][eE][sS]|[yY])
 rm -rf $nkt/*
 if [ -f "/home/.Nukkit/nukkit-1.0-SNAPSHOT.jar" ];then
 echo "删除失败"
 echo "请手动输入:rm -rf /home/ubuntu/Nukkit"
 else
 echo "删除成功"
 fi
 sh $sh/mctermux.sh 
 ;;
 [nN])
 sh $sh/mctermux.sh
 esac
 ;;
 3)
 echo "读取文件内容"
 read -p "端口: " bk
 sed -i "5c server-port=$bk" $nkt/server.properties
 sh $sh/mctermux.sh 
 ;;
 
 4)
 echo "============"
 echo "取消:ctrl + c"
 echo "[3]冒险"
 echo "[1]创造"
 echo "[0]生存"
 echo "============"
 read -p "模式: " ms
 sed -i "16c gamemode=$ms" $nkt/server.properties
 sh $sh/mctermux.sh 
 ;;
 
 5)  
 read -p "服务器名: " mz
 sed -i "3c motd=$mz" $nkt/server.properties
 sh $sh/mctermux.sh 
 ;;
 
 6)
 cd $nkt
 rm $nkt/nukkit-1.0-SNAPSHOT.jar
 wget $http
 echo "\033[32m $e 执行成功 \033[0m"
 sh $sh/mctermux.sh 
 ;;

 7)
 cd $nkt/plugins/
 sl=$(ls -l |grep "^-"|wc -l)
 mv $nkt/plugins/* $sys/NK/mod
 echo "\033[32m $e 执行成功 \033[0m"
 echo "\033[32m $e 保存至:$sys/NK/mod \033[0m"
 echo "\033[32m $e 共移除mood:$sl \033[0m"
 sh $sh/mctermux.sh 
 ;;
 8)
 mv $sys/NK/mod/* $nkt/plugins/
 echo "\033[32m $e 执行成功 \033[0m"
 echo "\033[32m $e $sys/NK/mod/ > $nkt/plugins \033[0m"
 cd $nkt/plugins/
 java=$(find * -type f -name "*.jar"  )
 sl=$(ls -l |grep "^-"|wc -l)
 echo "\033[32m $e 共载入mood:$sl java文件:$java\033[0m"
 sh $sh/mctermux.sh 
 ;;
 
 9)
 echo "\033[32m $e 备份文件目录:$sys/NK/Backups \033[0m"
 echo "[0]\033[32m $e 备份配置文件 \033[0m"
 echo "[1]\033[32m $e 备份世界文件 \033[0m"
 echo "[2]\033[32m $e 备份mood文件 \033[0m"
 echo "[3]\033[32m $e 备份服务器核心 \033[0m"
 echo "[4]\033[32m $e 备份所有文件  \033[0m"
 echo "[5]\033[32m $e 备份恢复  \033[0m"
 echo "[6]\033[34m $e 恢复mood  \033[0m"
 echo "[7]\033[34m $e 恢复worlds (世界)  \033[0m"
 echo "[8]\033[34m $e 恢复核心  \033[0m"
 echo "[9]\033[34m $e 配置文件  \033[0m"
 read -p "备份选择:" bf
 case $bf in
 0)
 cp -r $nkt/server.properties $sys/NK/Backups
 echo "\033[32m $e 备份完成  \033[0m"
 sh $sh/mctermux.sh 
 ;;
 1)
 cp -r $nkt/worlds $sys/NK/Backups
 echo "\033[32m $e 备份完成  \033[0m"
 sh $sh/mctermux.sh 
 ;;
 2)
 cp $nkt/plugins $sys/NK/Backups
 echo "\033[32m $e 备份完成  \033[0m"
 sh $sh/mctermux.sh 
 ;;
 3)
 cp -r $nkt/nukkit-1.0-SNAPSHOT.jar $sys/NK/Backups
 echo "\033[32m $e 备份完成  \033[0m"
 sh $sh/mctermux.sh 
 ;;
 4)
 mkdir $sys/NK/Backups/Nukkit
 mkdir $sys/NK/Backups/plugins
 mkdir $sys/NK/Backups/worlds/
 mkdir $sys/NK/Backups/moodBackups
 cp $nkt/* $sys/NK/Backups/Nukkit
 cp $nkt/plugins/* $sys/NK/Backups/p
 cp $nkt/worlds/* $sys/NK/Backups/worlds
 echo "\033[32m $e 备份完成  \033[0m"
 sh $sh/mctermux.sh 
 ;;
 5)
 mv $sys/NK/Backups/plugins/* $nkt/plugins
 mv $sys/NK/Backups/Nukkit/* $nkt
 mv $sys/NK/Backups/worlds/* $nkt/worlds
 echo "\033[32m $e 恢复完成  \033[0m"
 sh $sh/mctermux.sh 
 ;;
 6)
 echo "选择备份:时间"
 ls -l $sys/NK/Backups/plugins
 ;;
 7)
 mv $sys/NK/Backups/worlds $nkt/worlds
 ;;
 8)
 mv $sys/NK/Backups/Nukkit/server.properties $nkt/
 esac
 sh $sh/mctermux.sh 
  ;;
  10)
  read -p "人数上限: " sx
 sed -i "12c max-players=$sx" $nkt/server.properties
 sh $sh/mctermux.sh 
 ;;
 11)
  echo "\033[32m $e -------ATSE脚本配置管理器------ \033[0m"
  echo "[0]\033[62m $e 打开配置文件 \033[0m"
  echo "[1]\033[32m $e 打开服务器配置文件 \033[0m"
  echo "[2]\033[32m $e 打开服务器目录 \033[0m"
  echo "[3]\033[32m $e 删除脚本全部模块 \033[0m"
  read -r -p "模式: " atse
  case $atse in
  0)
  nano /data/data/com.termux/files/usr/.ACTS/User/xml.xml 
  sh $sh/mctermux.sh
  ;;
  1)
  nano $nkt/server.properties 
  sh $sh/mctermux.sh
  ;;
  2)
  cd $nk
  ;;
  3)
   echo "\033[33m $e [ATSE]:删除脚本核心所有文件 \033[0m"
   read -r -p  "\033[33m $e 此操作不可逆,您确定吗[Y/N]？ \033[0m" ipu
case $ipu in
    [yY])
rm -rf /data/data/com.termux/files/usr/.ACTS/
echo "\033[32m $e rm 配置文件...ok \033[0m"
sleep 1
rm -rf $sh/yh.sh
echo "\033[32m $e ATSE文件..ok \033[0m"
sleep 1
rm -rf $sh/User
echo "\033[32m $e User配置文件...ok \033[0m"
sleep 1
rm -rf $nk
echo "\033[32m $e 服务器配置文件...ok \033[0m"       
rm -rf $sys
echo "\033[32m $e 管理目录文件..ok \033[0m"
rm -rf $sh/mctermux.sh
echo "\033[32m $e 核心文件..ok \033[0m"
sleep 2
echo "\033[32m $e [ATSE]:已删除脚本创建文件 \033[0m"
echo "\033[32m $e 删除执行完成 \033[0m"
;;
[nY])
echo "取消"
esac
;;
esac
 ;;
12)
 echo "\033[32m $e 正在执行一个无用指令 \033[0m"
esac